<?php

namespace App\Models;

class Goods extends BaseModel
{
    protected $table = 'goods';

    protected $fillable = [
        'source_id',
        'title',
        'user_id',
        'property',
        'category_id',
        'price',
        'pic',
        'content',
        'sort',
        'hot',
        'like',
        'qrcode',
        'status',
    ];
    public function getPicAttribute($value)
    {
        return $value ? explode(',', $value) : [];
    }
//
//    public function setPicAttribute($value)
//    {
//        $this->attributes['pic'] = $value ? implode(',', $value) : null;
//    }
    public function user()
    {
        return $this->hasOne(User::class, 'id', 'user_id')->select('id', 'nickname','avatar');
    }
}
